﻿@model Host.Models.ClientModel
@{
    ViewBag.Title = "Clients";
}
<link type="text/css" rel="stylesheet" href="@Url.Content("~/Content/System/Clients.css")"></link>
<h2>Clients</h2>
<p>The current clients in the system. Click the edit button to change client information.</p>
  @using (Html.BeginForm("Clients", "System", new { id = "Clients" }))
  {
      {
          var grid = new WebGrid(canPage: true, rowsPerPage: Host.Controllers.SystemController.ClientPageSize,
                                 canSort: true, ajaxUpdateContainerId: "grid", ajaxUpdateCallback: "updateStyle");
          grid.Bind(Model.Clients, rowCount: Model.TotalRecords, autoSortAndPage: false);

          @grid.GetHtml(
              tableStyle: "ui-grid-content ui-widget-content",
              headerStyle: "ui-grid-header ui-widget-header ui-corner-top ui-state-default",
              footerStyle: "ui-grid-footer ui-widget-header ui-corner-bottom ",
              alternatingRowStyle: "webgrid-alternating-rows",
              htmlAttributes: new {id = "grid"},
              columns: grid.Columns(
                  grid.Column("ClientName"),
                  grid.Column("Active"),
                  grid.Column("PhysicalAddress"),
                  grid.Column("PostalAddress"),
                  grid.Column(format: @<a href='#' onclick=" Edit(@item.ClientId, '@item.ClientName', '@item.Active', '@item.PostalAddress', '@item.PhysicalAddress')" >Edit</a>)
                  ))
      }
  }
    <div style="display: none;">
        <div id="EditDialog" title="Edit Client">
        @using (Html.BeginForm("Clients", "System", FormMethod.Post, new { id = "ClientsForm" }))
{
    <fieldset>
        <legend>Client Information</legend>
        <table>
            <tr>
                <td colspan="2">
                    @Html.HiddenFor(m => m.ClientId) 
                    @Html.HiddenFor(m=> m.Clients) 
                    @Html.HiddenFor(m=> m.TotalRecords) 
                    @Html.HiddenFor(m=> m.CreatedBy)
                    @Html.HiddenFor(m=> m.PageNumber)
                    @Html.HiddenFor(m=> m.PageSize)
                    @Html.HiddenFor(m=> m.DateCreated)
                    @Html.HiddenFor(m=> m.Update)
                </td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.ClientName):</td>
                <td>@Html.TextBoxFor(m => m.ClientName)</td>
            </tr>
            <tr>
                <td id="ActiveCol">Active:</td>
                <td ><input type="checkbox" id="activebox"/> @Html.HiddenFor(m=> m.Active)</td>
            </tr>
            <tr class="MultiRow">
                <td>@Html.LabelFor(model => model.PhysicalAddress):</td>
                <td>@Html.TextAreaFor(m => m.PhysicalAddress)</td>
            </tr>
            <tr class="MultiRow">
                <td>@Html.LabelFor(model => model.PostalAddress):</td>
                <td>@Html.TextAreaFor(m => m.PostalAddress)</td>
            </tr>
        </table>
    </fieldset>
}
        </div>
    </div>
    <script type="text/javascript" src="@Url.Content("~/Scripts/System/Clients.js")" ></script>
